package com.pai4j.domain.community.vo.request;

import com.chat4j.common.enums.QuestionTypeEnum;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;

import java.util.List;

/**
 * @Author 程序员七七
 * @webSite https://www.coderutil.com
 * @Date 2022/12/18 02:57
 * @description
 */
@Data
public class CCQuestionSaveRequestVO {

    protected Long id;

    private Long pathId;

    private String title;

    private String description;

    private List<String> images;

    private String author;

    private Integer type;

    private Integer rewardIntegral;

    private String signs;

    public void validate() {
        Assert.isTrue(this.pathId != null, "技术专区未查找到！");
        Assert.isTrue(QuestionTypeEnum.validateType(type), "不支持的问题类型！");
        Assert.isTrue(StringUtils.isNotBlank(title) && title.length() <= 100, "问题标题不能为空，且控制在100字以内");
        if (StringUtils.isNotBlank(description)) {
            Assert.isTrue(description.length() <= 1000, "问题描述控制在1000字以内");
        }
        if (StringUtils.isNotBlank(signs)) {
            Assert.isTrue(signs.length() <= 200, "标签长度非法");
        }
    }
}
